<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="主表id" prop="excelId">
        <el-input v-model="queryParams.excelId" placeholder="请输入主表id" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="击实次数" prop="jiscs">
        <el-input v-model="queryParams.jiscs" placeholder="请输入击实次数" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="试样编号


" prop="shiybh">
        <el-input v-model="queryParams.shiybh" placeholder="请输入试样编号


" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筒号" prop="tongh">
        <el-input v-model="queryParams.tongh" placeholder="请输入筒号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="泡水前试件高度" prop="paosqsjgd">
        <el-input v-model="queryParams.paosqsjgd" placeholder="请输入泡水前试件高度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="泡水后试件高度" prop="paoshsjgd">
        <el-input v-model="queryParams.paoshsjgd" placeholder="请输入泡水后试件高度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="膨胀量" prop="pengzl">
        <el-input v-model="queryParams.pengzl" placeholder="请输入膨胀量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筒质量" prop="tongzl">
        <el-input v-model="queryParams.tongzl" placeholder="请输入筒质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筒+试件质量" prop="tongjsjzl">
        <el-input v-model="queryParams.tongjsjzl" placeholder="请输入筒+试件质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="筒体积" prop="tongtj">
        <el-input v-model="queryParams.tongtj" placeholder="请输入筒体积" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="湿密度" prop="shimd">
        <el-input v-model="queryParams.shimd" placeholder="请输入湿密度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="含水率" prop="hansl">
        <el-input v-model="queryParams.hansl" placeholder="请输入含水率" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="干密度" prop="ganmd">
        <el-input v-model="queryParams.ganmd" placeholder="请输入干密度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒号" prop="heh">
        <el-input v-model="queryParams.heh" placeholder="请输入盒号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒质量" prop="hezl">
        <el-input v-model="queryParams.hezl" placeholder="请输入盒质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒+湿土质量" prop="hejstzl">
        <el-input v-model="queryParams.hejstzl" placeholder="请输入盒+湿土质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="盒+干土质量" prop="hejgtzl">
        <el-input v-model="queryParams.hejgtzl" placeholder="请输入盒+干土质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="水分质量" prop="shifzl">
        <el-input v-model="queryParams.shifzl" placeholder="请输入水分质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="干土质量" prop="gantzl">
        <el-input v-model="queryParams.gantzl" placeholder="请输入干土质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="泡水后筒+试件质量" prop="paoshtjsjzl">
        <el-input v-model="queryParams.paoshtjsjzl" placeholder="请输入泡水后筒+试件质量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="吸水量" prop="xisl">
        <el-input v-model="queryParams.xisl" placeholder="请输入吸水量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb5 top-right-btn small-line-height">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['report_tg:tgTdczbjlbyBaDetail:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['report_tg:tgTdczbjlbyBaDetail:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['report_tg:tgTdczbjlbyBaDetail:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['report_tg:tgTdczbjlbyBaDetail:export']">导出</el-button>
      </el-col>
      <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
    </el-row>

    <el-table border stripe v-loading="loading" :data="tgTdczbjlbyBaDetailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" v-if="true" />
      <el-table-column label="主表id" align="center" prop="excelId" />
      <el-table-column label="击实次数" align="center" prop="jiscs" />
      <el-table-column label="试样编号


" align="center" prop="shiybh" />
      <el-table-column label="筒号" align="center" prop="tongh" />
      <el-table-column label="泡水前试件高度" align="center" prop="paosqsjgd" />
      <el-table-column label="泡水后试件高度" align="center" prop="paoshsjgd" />
      <el-table-column label="膨胀量" align="center" prop="pengzl" />
      <el-table-column label="筒质量" align="center" prop="tongzl" />
      <el-table-column label="筒+试件质量" align="center" prop="tongjsjzl" />
      <el-table-column label="筒体积" align="center" prop="tongtj" />
      <el-table-column label="湿密度" align="center" prop="shimd" />
      <el-table-column label="含水率" align="center" prop="hansl" />
      <el-table-column label="干密度" align="center" prop="ganmd" />
      <el-table-column label="盒号" align="center" prop="heh" />
      <el-table-column label="盒质量" align="center" prop="hezl" />
      <el-table-column label="盒+湿土质量" align="center" prop="hejstzl" />
      <el-table-column label="盒+干土质量" align="center" prop="hejgtzl" />
      <el-table-column label="水分质量" align="center" prop="shifzl" />
      <el-table-column label="干土质量" align="center" prop="gantzl" />
      <el-table-column label="泡水后筒+试件质量" align="center" prop="paoshtjsjzl" />
      <el-table-column label="吸水量" align="center" prop="xisl" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['report_tg:tgTdczbjlbyBaDetail:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['report_tg:tgTdczbjlbyBaDetail:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改土的承载比一 详细对话框 -->
    <jy-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="主表id" prop="excelId">
          <el-input v-model="form.excelId" placeholder="请输入主表id" />
        </el-form-item>
        <el-form-item label="击实次数" prop="jiscs">
          <el-input v-model="form.jiscs" placeholder="请输入击实次数" />
        </el-form-item>
        <el-form-item label="试样编号


" prop="shiybh">
          <el-input v-model="form.shiybh" placeholder="请输入试样编号


" />
        </el-form-item>
        <el-form-item label="筒号" prop="tongh">
          <el-input v-model="form.tongh" placeholder="请输入筒号" />
        </el-form-item>
        <el-form-item label="泡水前试件高度" prop="paosqsjgd">
          <el-input v-model="form.paosqsjgd" placeholder="请输入泡水前试件高度" />
        </el-form-item>
        <el-form-item label="泡水后试件高度" prop="paoshsjgd">
          <el-input v-model="form.paoshsjgd" placeholder="请输入泡水后试件高度" />
        </el-form-item>
        <el-form-item label="膨胀量" prop="pengzl">
          <el-input v-model="form.pengzl" placeholder="请输入膨胀量" />
        </el-form-item>
        <el-form-item label="筒质量" prop="tongzl">
          <el-input v-model="form.tongzl" placeholder="请输入筒质量" />
        </el-form-item>
        <el-form-item label="筒+试件质量" prop="tongjsjzl">
          <el-input v-model="form.tongjsjzl" placeholder="请输入筒+试件质量" />
        </el-form-item>
        <el-form-item label="筒体积" prop="tongtj">
          <el-input v-model="form.tongtj" placeholder="请输入筒体积" />
        </el-form-item>
        <el-form-item label="湿密度" prop="shimd">
          <el-input v-model="form.shimd" placeholder="请输入湿密度" />
        </el-form-item>
        <el-form-item label="含水率" prop="hansl">
          <el-input v-model="form.hansl" placeholder="请输入含水率" />
        </el-form-item>
        <el-form-item label="干密度" prop="ganmd">
          <el-input v-model="form.ganmd" placeholder="请输入干密度" />
        </el-form-item>
        <el-form-item label="盒号" prop="heh">
          <el-input v-model="form.heh" placeholder="请输入盒号" />
        </el-form-item>
        <el-form-item label="盒质量" prop="hezl">
          <el-input v-model="form.hezl" placeholder="请输入盒质量" />
        </el-form-item>
        <el-form-item label="盒+湿土质量" prop="hejstzl">
          <el-input v-model="form.hejstzl" placeholder="请输入盒+湿土质量" />
        </el-form-item>
        <el-form-item label="盒+干土质量" prop="hejgtzl">
          <el-input v-model="form.hejgtzl" placeholder="请输入盒+干土质量" />
        </el-form-item>
        <el-form-item label="水分质量" prop="shifzl">
          <el-input v-model="form.shifzl" placeholder="请输入水分质量" />
        </el-form-item>
        <el-form-item label="干土质量" prop="gantzl">
          <el-input v-model="form.gantzl" placeholder="请输入干土质量" />
        </el-form-item>
        <el-form-item label="泡水后筒+试件质量" prop="paoshtjsjzl">
          <el-input v-model="form.paoshtjsjzl" placeholder="请输入泡水后筒+试件质量" />
        </el-form-item>
        <el-form-item label="吸水量" prop="xisl">
          <el-input v-model="form.xisl" placeholder="请输入吸水量" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button size="small" @click="cancel">取 消</el-button>
      </div>
    </jy-dialog>
  </div>
</template>

<script>
import { listTgTdczbjlbyBaDetail, getTgTdczbjlbyBaDetail, delTgTdczbjlbyBaDetail, addTgTdczbjlbyBaDetail, updateTgTdczbjlbyBaDetail } from "@/api/report_tg/tgTdczbjlbyBaDetail";

export default {
  name: "TgTdczbjlbyBaDetail",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 土的承载比一 详细表格数据
      tgTdczbjlbyBaDetailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        excelId: undefined,
        jiscs: undefined,
        shiybh: undefined,
        tongh: undefined,
        paosqsjgd: undefined,
        paoshsjgd: undefined,
        pengzl: undefined,
        tongzl: undefined,
        tongjsjzl: undefined,
        tongtj: undefined,
        shimd: undefined,
        hansl: undefined,
        ganmd: undefined,
        heh: undefined,
        hezl: undefined,
        hejstzl: undefined,
        hejgtzl: undefined,
        shifzl: undefined,
        gantzl: undefined,
        paoshtjsjzl: undefined,
        xisl: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [{ required: true, message: "id不能为空", trigger: "blur" }],
        excelId: [{ required: true, message: "主表id不能为空", trigger: "blur" }],
        jiscs: [{ required: true, message: "击实次数不能为空", trigger: "blur" }],
        shiybh: [{ required: true, message: "试样编号不能为空", trigger: "blur" }],
        tongh: [{ required: true, message: "筒号不能为空", trigger: "blur" }],
        paosqsjgd: [{ required: true, message: "泡水前试件高度不能为空", trigger: "blur" }],
        paoshsjgd: [{ required: true, message: "泡水后试件高度不能为空", trigger: "blur" }],
        pengzl: [{ required: true, message: "膨胀量不能为空", trigger: "blur" }],
        tongzl: [{ required: true, message: "筒质量不能为空", trigger: "blur" }],
        tongjsjzl: [{ required: true, message: "筒+试件质量不能为空", trigger: "blur" }],
        tongtj: [{ required: true, message: "筒体积不能为空", trigger: "blur" }],
        shimd: [{ required: true, message: "湿密度不能为空", trigger: "blur" }],
        hansl: [{ required: true, message: "含水率不能为空", trigger: "blur" }],
        ganmd: [{ required: true, message: "干密度不能为空", trigger: "blur" }],
        heh: [{ required: true, message: "盒号不能为空", trigger: "blur" }],
        hezl: [{ required: true, message: "盒质量不能为空", trigger: "blur" }],
        hejstzl: [{ required: true, message: "盒+湿土质量不能为空", trigger: "blur" }],
        hejgtzl: [{ required: true, message: "盒+干土质量不能为空", trigger: "blur" }],
        shifzl: [{ required: true, message: "水分质量不能为空", trigger: "blur" }],
        gantzl: [{ required: true, message: "干土质量不能为空", trigger: "blur" }],
        paoshtjsjzl: [{ required: true, message: "泡水后筒+试件质量不能为空", trigger: "blur" }],
        xisl: [{ required: true, message: "吸水量不能为空", trigger: "blur" }]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询土的承载比一 详细列表 */
    getList() {
      this.loading = true;
      listTgTdczbjlbyBaDetail(this.queryParams).then((response) => {
        this.tgTdczbjlbyBaDetailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        excelId: undefined,
        jiscs: undefined,
        shiybh: undefined,
        tongh: undefined,
        paosqsjgd: undefined,
        paoshsjgd: undefined,
        pengzl: undefined,
        tongzl: undefined,
        tongjsjzl: undefined,
        tongtj: undefined,
        shimd: undefined,
        hansl: undefined,
        ganmd: undefined,
        heh: undefined,
        hezl: undefined,
        hejstzl: undefined,
        hejgtzl: undefined,
        shifzl: undefined,
        gantzl: undefined,
        paoshtjsjzl: undefined,
        xisl: undefined,
        delFlag: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加土的承载比一 详细";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids;
      getTgTdczbjlbyBaDetail(id).then((response) => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改土的承载比一 详细";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateTgTdczbjlbyBaDetail(this.form)
              .then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              })
              .finally(() => {
                this.buttonLoading = false;
              });
          } else {
            addTgTdczbjlbyBaDetail(this.form)
              .then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              })
              .finally(() => {
                this.buttonLoading = false;
              });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除土的承载比一 详细编号为"' + ids + '"的数据项？')
        .then(() => {
          this.loading = true;
          return delTgTdczbjlbyBaDetail(ids);
        })
        .then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {})
        .finally(() => {
          this.loading = false;
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "report_tg/tgTdczbjlbyBaDetail/export",
        {
          ...this.queryParams
        },
        `tgTdczbjlbyBaDetail_${new Date().getTime()}.xlsx`
      );
    }
  }
};
</script>
